package com.kingyea.app.market.Dictionary.service.impl;

import com.kingyea.app.market.Dictionary.bean.Dictionary;
import com.kingyea.app.market.Dictionary.dao.DictionaryMapper;
import com.kingyea.app.market.Dictionary.service.DictionaryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author
 * @version v1.0.0
 * @description Dictionary 实现类
 * @date Created in 2018-02-23 17:02:59
 */
@Service
@Transactional
public class DictionaryServiceImpl implements DictionaryService {

    private static final Logger LOGGER = LoggerFactory.getLogger(DictionaryServiceImpl.class);

    @Resource
    private DictionaryMapper dictionaryMapper;

    /**
     * 通过ID查找对象
     *
     * @param id
     * @return
     */
    @Override
    public Dictionary getById(Integer id) throws Exception {
        return this.dictionaryMapper.getById(id);
    }

    /**
     * 列表
     *
     * @param
     * @return
     */
    @Override
    public List<Dictionary> list(Dictionary dictionary) throws Exception {
        List<Dictionary> list = dictionaryMapper.list(dictionary);
        return list;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public int deleteById(Integer id) throws Exception {
        dictionaryMapper.deleteById(id);
        return 1;
    }

    /**
     * 保存
     *
     * @param dictionary
     * @return
     */
    @Override
    public Dictionary save(Dictionary dictionary) throws Exception {
        try {
            dictionaryMapper.save(dictionary);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dictionary;
    }

    /**
     * 更新
     *
     * @param dictionary
     * @return
     */
    @Override
    public Dictionary update(Dictionary dictionary) throws Exception {
        try {
            dictionaryMapper.update(dictionary);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dictionary;
    }


}
